home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 20
/
Aminet 20 (1997)(GTI - Schatztruhe)[!][Aug 1997].iso
/
Aminet
/
comm
/
www
/
N2v.lha
/
N2V.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-31
|
2KB
|
101 lines
/* Netscape to Voyager Bookmark file converter */
#include <libraries/dosextens.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Copyright(void);
/* constants declaration */
#define MAXBUF 128
#define MAXINBUF 4097
#define MAXOUTBUF 128
/* variables declaration */
char filein[MAXBUF], filelow[MAXBUF];
char databuf[MAXINBUF];
char *pointer, *ptr;
FILE *fi, *fl;
char *prolog= "<! Voyager - Bookmarks.mcc >\n<!!! This is automatically generated... Do NOT edit !!!>\n<HTML>\n<TITLE>Voyager Bookmarks</TITLE>\n<BODY>\n\n<H1 ALIGN=CENTER>Voyager Bookmarks</H1>\n<HR>\n";
char *postlog= "<BR>\n<HR>\n<a href=\"About:\">Voyager 2.88 (20.05.97)</a>\n</BODY>\n</HTML>";
main(argc, argv)
int argc;
char *argv[];
{
int i=1;
Copyright();
if(argc==1) {
badusage: printf("Usage: %s filename [filename]\n",argv[0]);
exit(1);
}
/* insert options handling here */
if(!(--argc))
goto badusage;
strcpy(filein,argv[i]);
strcpy(filelow,filein);
strcat(filelow,".html");
if(--argc)
strcpy(filelow,argv[++i]);
if(!(fi=fopen(filein,"r"))) {
printf("Can't open file %s for input\n",filein);
exit(1);
}
if(!(fl=fopen(filelow,"w"))) {
printf("Can't open file %s for output\n",filelow);
fclose(fi);
exit(1);
}
fputs(prolog,fl);
while(fgets(databuf,sizeof(databuf),fi)){
pointer=stpblk(databuf);
if(i=stcsma(pointer,"<DL>*"))
fputs("<UL>\n",fl);
if(i=stcsma(pointer,"</DL>*"))
fputs("</UL>\n",fl);
if(i=stcsma(pointer,"<DT>*")) {
fputs("<LI>",fl);
pointer+=4;
pointer=stpblk(pointer);
if(i=stcsma(pointer,"<H*")) {
ptr=strtok(pointer,">");
pointer=strtok(NULL,"<");
fputs(pointer,fl);
}
else if(i=stcsma(pointer,"<A HREF=*")) {
ptr=strtok(pointer,"\"");
pointer=strtok(NULL,"\"");
fputs("<A HREF=\"",fl);
fputs(pointer,fl);
fputs("\">",fl);
pointer=strtok(NULL,">");
pointer=strtok(NULL,"\0");
fputs(pointer,fl);
}
}
/* DT DL DT /DL */
}
fputs(postlog,fl);
fclose(fi);
fclose(fl);
}
void Copyright(void)
{
puts("Netscrap to Voyager bookmarks file converter (C)1997 by SRC");
}